package main

import (
	"log"
)

func isSubsequence(s string, t string) bool {
	if len(s) > len(t) {
		return false
	}
	//双指针
	tIndex := 0
	for sIndex := 0; sIndex < len(s); sIndex++ {
		for ; tIndex < len(t) && s[sIndex] != t[tIndex]; tIndex++ {
		}
		if tIndex == len(t) {
			return false
		}
		tIndex++
	}
	return true
}

func main() {
	//eq(isSubsequence("abc", "ahbgdc"), false, 1)
	eq(isSubsequence("bb", "ahbgdc"), false, 2)
}

func eq(a interface{}, b interface{}, res interface{}) {
	if a != b {
		log.Fatal(res)
	}
}
